import json 
import numpy as np

class Ego_pose:
    def __init__(self,q,t):
        self.rot = np.array(q)
        self.t = np.array(t)

class Sensor_data:
    def __init__(self,sensor_name,ref_file_path,stamp,ego_pose,sample_data_token):
        self.sensor_name = sensor_name 
        self.ref_file_path = ref_file_path
        self.stamp = stamp
        self.ego_pose = Ego_pose(ego_pose['rotation'],ego_pose['translation'])
        self.sample_data_token = sample_data_token  # 可以根据这个token 去sample token 中找对应的信息，包括是否为关键帧等
        
def load_json(json_file_path):
    f = open(json_file_path,'r')
    json_file = json.load(f)
    return json_file

def gen_dict_from_raw_json(nusc_json):
    token_data_dict = {data_dict['token'] : data_dict for data_dict in nusc_json}
    return token_data_dict
